/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class CartModifyRequest
    {
    
        private String cartIdField;

        private String HMACField;

        private String mergeCartField;

        private  CartModifyItems itemsField;
        private List<String> responseGroupField;


        /// <summary>
        /// Gets and sets the CartId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "CartId")]
        public String CartId
        {
            get { return this.cartIdField ; }
            set { this.cartIdField= value; }
        }



        /// <summary>
        /// Sets the CartId property
        /// </summary>
        /// <param name="cartId">CartId property</param>
        /// <returns>this instance</returns>
        public CartModifyRequest WithCartId(String cartId)
        {
            this.cartIdField = cartId;
            return this;
        }



        /// <summary>
        /// Checks if CartId property is set
        /// </summary>
        /// <returns>true if CartId property is set</returns>
        public Boolean IsSetCartId()
        {
            return  this.cartIdField != null;

        }


        /// <summary>
        /// Gets and sets the HMAC property.
        /// </summary>
        [XmlElementAttribute(ElementName = "HMAC")]
        public String HMAC
        {
            get { return this.HMACField ; }
            set { this.HMACField= value; }
        }



        /// <summary>
        /// Sets the HMAC property
        /// </summary>
        /// <param name="HMAC">HMAC property</param>
        /// <returns>this instance</returns>
        public CartModifyRequest WithHMAC(String HMAC)
        {
            this.HMACField = HMAC;
            return this;
        }



        /// <summary>
        /// Checks if HMAC property is set
        /// </summary>
        /// <returns>true if HMAC property is set</returns>
        public Boolean IsSetHMAC()
        {
            return  this.HMACField != null;

        }


        /// <summary>
        /// Gets and sets the MergeCart property.
        /// </summary>
        [XmlElementAttribute(ElementName = "MergeCart")]
        public String MergeCart
        {
            get { return this.mergeCartField ; }
            set { this.mergeCartField= value; }
        }



        /// <summary>
        /// Sets the MergeCart property
        /// </summary>
        /// <param name="mergeCart">MergeCart property</param>
        /// <returns>this instance</returns>
        public CartModifyRequest WithMergeCart(String mergeCart)
        {
            this.mergeCartField = mergeCart;
            return this;
        }



        /// <summary>
        /// Checks if MergeCart property is set
        /// </summary>
        /// <returns>true if MergeCart property is set</returns>
        public Boolean IsSetMergeCart()
        {
            return  this.mergeCartField != null;

        }


        /// <summary>
        /// Gets and sets the Items property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Items")]
        public CartModifyItems Items
        {
            get { return this.itemsField ; }
            set { this.itemsField = value; }
        }



        /// <summary>
        /// Sets the Items property
        /// </summary>
        /// <param name="items">Items property</param>
        /// <returns>this instance</returns>
        public CartModifyRequest WithItems(CartModifyItems items)
        {
            this.itemsField = items;
            return this;
        }



        /// <summary>
        /// Checks if Items property is set
        /// </summary>
        /// <returns>true if Items property is set</returns>
        public Boolean IsSetItems()
        {
            return this.itemsField != null;
        }




        /// <summary>
        /// Gets and sets the ResponseGroup property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ResponseGroup")]
        public List<String> ResponseGroup
        {
            get
            {
                if (this.responseGroupField == null)
                {
                    this.responseGroupField = new List<String>();
                }
                return this.responseGroupField;
            }
            set { this.responseGroupField =  value; }
        }



        /// <summary>
        /// Sets the ResponseGroup property
        /// </summary>
        /// <param name="list">ResponseGroup property</param>
        /// <returns>this instance</returns>
        public CartModifyRequest WithResponseGroup(params String[] list)
        {
            foreach (String item in list)
            {
                ResponseGroup.Add(item);
            }
            return this;
        }          
 


        /// <summary>
        /// Checks of ResponseGroup property is set
        /// </summary>
        /// <returns>true if ResponseGroup property is set</returns>
        public Boolean IsSetResponseGroup()
        {
            return (ResponseGroup.Count > 0);
        }






        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetCartId()) {
                xml.Append("<CartId>");
                xml.Append(EscapeXML(this.CartId));
                xml.Append("</CartId>");
            }
            if (IsSetHMAC()) {
                xml.Append("<HMAC>");
                xml.Append(EscapeXML(this.HMAC));
                xml.Append("</HMAC>");
            }
            if (IsSetMergeCart()) {
                xml.Append("<MergeCart>");
                xml.Append(EscapeXML(this.MergeCart));
                xml.Append("</MergeCart>");
            }
            if (IsSetItems()) {
                CartModifyItems  items = this.Items;
                xml.Append("<Items>");
                xml.Append(items.ToXMLFragment());
                xml.Append("</Items>");
            } 
            List<String> responseGroupList  =  this.ResponseGroup;
            foreach (String responseGroup in responseGroupList) { 
                xml.Append("<ResponseGroup>");
                xml.Append(responseGroup);
                xml.Append("</ResponseGroup>");
            }	
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}